

package metadatabrowser;

import at.fhj.itm.metadata.ForeignKeyConstraint;
import at.fhj.util.Pair;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.Viewer;

/**
 *
 * @author Seuchter
 */
public class ForeignKeyConstraintContentProvider extends  AbstractKeyConstraintContentProvider {



    @Override
    public Object[] getElements(Object o)
    {
      if(!(o instanceof ForeignKeyConstraint))
      {
        return null;
      }

      ForeignKeyConstraint fkey = (ForeignKeyConstraint) o;

      List<Pair<String,String>> properties = new ArrayList<Pair<String, String>>();
      properties.addAll(createCommonProperties(fkey));
      properties.add(new Pair<String, String>("Referencing Table",
              fkey.getReferencingTable().getName()));
      properties.add(new Pair<String, String>("Referencing Column",
              createColumnList(fkey.getReferencingColumns())));

      properties.add(new Pair<String, String>("On Update", fkey.getUpdateAction()));
      properties.add(new Pair<String, String>("On Delete", fkey.getDeleteAction()));


      return properties.toArray();
    }

    @Override
    public void dispose()
    {

    }

    @Override
    public void inputChanged(Viewer viewer, Object o, Object o1)
    {

    }

}
